<template>
    <div>
      <div>msgWall</div>
      <ul>
        <li v-for="item in msgWall" :key="item.id">
          <div>{{item.username}}</div>
          <img :src="item.avatar">
          <div>{{item.msg}}</div>
        </li>
      </ul>
      <router-link to="/"><span>return</span></router-link>
    </div>
</template>

<script>

export default {
  name: 'msgWall',
  data () {
    return {
      msgWall: [{
        username: '小编',
        avatar: '',
        msg: '正在拼命加载的小编'
      }],
      time: ''
    }
  },
  methods: {
    update () {
      this.$http.get('/api/msgWall').then((response) => {
        response = response.body
        this.msgWall = response.data
        console.log(this.msgWall)
      })
    }
  },
  activated () {
    this.time = setInterval(this.update, 2000)
  },
  deactivated () {
    clearInterval(this.time)
  }
}
</script>

<style>
</style>